using vue0701.Infrastructure.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using vue0701.Domain.Reposoitiories;
using vue0701.Infrastructure.Reposoitiories;
using vue0701.Application.Common.interfaces;
using vue0701.Infrastructure.Security;



namespace vue0701.Infrastructure;

public static class ServiceCollectionExtensions
    {
         public static IServiceCollection AddInfrastructure(this IServiceCollection services, IConfiguration configuration)
    {
        services.AddDbContext<Vue0701DbContext>(options =>
            options.UseMySql(
                configuration.GetConnectionString("mysql"),
                new MySqlServerVersion(new Version(8, 0, 34)) // 根据实际MySQL版本调整
            ));
            services.AddScoped(typeof(IRepository<>),typeof(EfRepository<>));
            services.AddSingleton(typeof(IPasswordHasher),typeof(PasswordHasher));
        return services;
    }
    }